package org.gdstash.ui;

import org.gdstash.db.*;
import org.gdstash.file.ARCDecompress;
import org.gdstash.file.ARCList;
import org.gdstash.file.ARZDecompress;
import org.gdstash.ui.character.GDCharMasteryImagePane;
import org.gdstash.ui.character.GDCharMasteryPane;
import org.gdstash.ui.select.*;
import org.gdstash.ui.util.AdjustablePanel;
import org.gdstash.ui.util.GDCharInfoList;
import org.gdstash.ui.util.GDStashInfoList;
import org.gdstash.util.*;

import javax.swing.*;
import javax.swing.border.Border;
import javax.swing.border.TitledBorder;
import javax.swing.text.AbstractDocument;
import javax.swing.text.DocumentFilter;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.io.File;
import java.io.IOException;
import java.sql.SQLException;
import java.util.LinkedList;
import java.util.List;

public class GDConfigPane extends AdjustablePanel {
    private GDStashFrame frame;
    private TitledBorder brdGeneral;
    private JButton btnHelp;
    private File dirGD;
    private String strGD;
    private JButton btnGD;
    private JLabel lblGD;
    private File dirSave;
    private String strSave;
    private JButton btnSave;
    private JLabel lblSave;
    private File dirExport;
    private String strExport;
    private JButton btnExport;
    private JLabel lblExport;
    private JLabel lblGDLocal;
    private JComboBox<String> cbGDLocal;
    private JLabel lblMod;
    private JComboBox<String> cbMod;
    private JLabel lblModStandalone;
    private JCheckBox cbModStandalone;
    private JLabel lblLanguage;
    private JComboBox<String> cbLanguage;
    private JLabel lblLookNFeel;
    private JComboBox<String> cbLookNFeel;
    private JLabel lblFontSize;
    private JComboBox<String> cbFontSize;
    private JLabel lblGraphicScale;
    private JComboBox<String> cbGraphicScale;
    private JLabel lblMinimizeTray;
    private JCheckBox cbMinimizeTray;
    private TitledBorder brdRestrict;
    private JCheckBox cbAllowEdit;
    private JCheckBox cbTransSCHC;
    private JCheckBox cbTransSoul;
    private JCheckBox cbCompletionAll;
    private JCheckBox cbBlacksmithAll;
    private JLabel lblDBStashMove;
    private JComboBox<String> cbDBStashMove;
    private TitledBorder brdCombi;
    private ButtonGroup bgCombi;
    private JRadioButton rbCombiValid;
    private JRadioButton rbCombiAllCombos;
    private JRadioButton rbCombiAllAffixes;
    private JButton btnConfig;
    private JButton btnDBImport;
    private JButton btnARZExport;
    private JButton btnDevotion;
    private JButton btnTexConvert;
    private JPanel pnlMain;

    public GDConfigPane(final GDStashFrame frame) {
        this.frame = frame;
        this.strGD = GDStashFrame.iniConfig.sectDir.gdPath;
        this.strSave = GDStashFrame.iniConfig.sectDir.savePath;
        this.adjustUI();
        GroupLayout layout = null;
        GroupLayout.SequentialGroup hGroup = null;
        GroupLayout.SequentialGroup vGroup = null;
        this.pnlMain = this.buildMainPanel();
        final JScrollPane scroll = new JScrollPane(this.pnlMain);
        scroll.getVerticalScrollBar().setUnitIncrement(2 * GDStashFrame.iniConfig.sectUI.fontSize);
        layout = new GroupLayout(this);
        this.setLayout(layout);
        layout.setAutoCreateGaps(true);
        layout.setAutoCreateContainerGaps(true);
        hGroup = layout.createSequentialGroup();
        hGroup.addGroup(layout.createParallelGroup().addComponent(scroll));
        layout.setHorizontalGroup(hGroup);
        vGroup = layout.createSequentialGroup();
        vGroup.addGroup(layout.createParallelGroup().addComponent(scroll));
        layout.setVerticalGroup(vGroup);
    }

    @Override
    public void adjustUI() {
        Font fntLabel = UIManager.getDefaults().getFont("Label.font");
        Font fntButton = UIManager.getDefaults().getFont("Button.font");
        if (fntButton == null) {
            fntButton = fntLabel;
        }
        Font fntCheck = UIManager.getDefaults().getFont("CheckBox.font");
        if (fntCheck == null) {
            fntCheck = fntLabel;
        }
        Font fntRadio = UIManager.getDefaults().getFont("RadioButton.font");
        if (fntRadio == null) {
            fntRadio = fntLabel;
        }
        Font fntCombo = UIManager.getDefaults().getFont("ComboBox.font");
        if (fntCombo == null) {
            fntCombo = fntLabel;
        }
        Font fntTip = UIManager.getDefaults().getFont("ToolTip.font");
        if (fntTip == null) {
            fntTip = fntLabel;
        }
        Font fntBorder = UIManager.getDefaults().getFont("TitledBorder.font");
        if (fntBorder == null) {
            fntBorder = fntLabel;
        }
        fntLabel = fntLabel.deriveFont((float) GDStashFrame.iniConfig.sectUI.fontSize);
        fntButton = fntButton.deriveFont((float) GDStashFrame.iniConfig.sectUI.fontSize);
        fntCheck = fntCheck.deriveFont((float) GDStashFrame.iniConfig.sectUI.fontSize);
        fntRadio = fntRadio.deriveFont((float) GDStashFrame.iniConfig.sectUI.fontSize);
        fntCombo = fntCombo.deriveFont((float) GDStashFrame.iniConfig.sectUI.fontSize);
        fntTip = fntTip.deriveFont((float) GDStashFrame.iniConfig.sectUI.fontSize);
        fntBorder = fntBorder.deriveFont((float) GDStashFrame.iniConfig.sectUI.fontSize);
        if (this.brdGeneral == null || this.brdRestrict == null || this.brdCombi == null) {
            final Border lowered = BorderFactory.createEtchedBorder(1);
            final Border raised = BorderFactory.createEtchedBorder(0);
            final Border compound = BorderFactory.createCompoundBorder(raised, lowered);
            if (this.brdGeneral == null) {
                this.brdGeneral = BorderFactory.createTitledBorder(compound);
            }
            if (this.brdRestrict == null) {
                this.brdRestrict = BorderFactory.createTitledBorder(compound);
            }
            if (this.brdCombi == null) {
                this.brdCombi = BorderFactory.createTitledBorder(compound);
            }
        }
        this.brdGeneral.setTitle(GDMsgFormatter.getString(GDMsgFormatter.rbUI, "BRD_GENERAL"));
        this.brdGeneral.setTitleFont(fntBorder);
        this.brdRestrict.setTitle(GDMsgFormatter.getString(GDMsgFormatter.rbUI, "BRD_RESTRICT"));
        this.brdRestrict.setTitleFont(fntBorder);
        this.brdCombi.setTitle(GDMsgFormatter.getString(GDMsgFormatter.rbUI, "BRD_AFFIX_COMBI"));
        this.brdCombi.setTitleFont(fntBorder);
        if (this.btnConfig == null) {
            (this.btnConfig = new JButton()).addActionListener(new ConfigListener());
        }
        this.btnConfig.setText(GDMsgFormatter.getString(GDMsgFormatter.rbUI, "BTN_SAVE_SETTINGS"));
        this.btnConfig.setIcon(GDImagePool.iconConfigSettingSave24);
        this.btnConfig.setFont(fntButton);
        if (this.btnDBImport == null) {
            (this.btnDBImport = new JButton()).addActionListener(new DBImportListener());
        }
        this.btnDBImport.setText(GDMsgFormatter.getString(GDMsgFormatter.rbUI, "BTN_DB_IMPORT"));
        this.btnDBImport.setIcon(GDImagePool.iconConfigDBImport24);
        this.btnDBImport.setFont(fntButton);
        if (this.btnARZExport == null) {
            (this.btnARZExport = new JButton()).addActionListener(new ARZExportListener());
        }
        this.btnARZExport.setText(GDMsgFormatter.getString(GDMsgFormatter.rbUI, "BTN_DB_EXPORT"));
        this.btnARZExport.setIcon(GDImagePool.iconConfigARZExport24);
        this.btnARZExport.setFont(fntButton);
        if (this.btnTexConvert == null) {
            (this.btnTexConvert = new JButton()).addActionListener(new TextureConversionListener());
        }
        this.btnTexConvert.setText(GDMsgFormatter.getString(GDMsgFormatter.rbUI, "BTN_TEXTURE_CONVERT"));
        this.btnTexConvert.setIcon(GDImagePool.iconConfigTextureConvert24);
        this.btnTexConvert.setFont(fntButton);
        if (this.btnDevotion == null) {
            (this.btnDevotion = new JButton()).addActionListener(new DevotionListener());
        }
        this.btnDevotion.setText(GDMsgFormatter.getString(GDMsgFormatter.rbUI, "BTN_DEVOTION_LIST"));
        this.btnDevotion.setIcon(GDImagePool.iconConfigDevotionList24);
        this.btnDevotion.setFont(fntButton);
        if (this.btnHelp == null) {
            (this.btnHelp = new JButton()).addActionListener(new GDHelpActionListener("01_config.html"));
        }
        this.btnHelp.setText(GDMsgFormatter.getString(GDMsgFormatter.rbUI, "BTN_HELP"));
        this.btnHelp.setIcon(GDImagePool.iconBtnQuestion24);
        this.btnHelp.setFont(fntButton);
        GDStashFrame.setMnemonic(this.btnHelp, "MNC_HELP");
        if (this.btnGD == null) {
            (this.btnGD = new JButton()).addActionListener(new GDDirListener());
        }
        this.btnGD.setText(GDMsgFormatter.getString(GDMsgFormatter.rbUI, "TXT_GD_INSTALL_DIR"));
        this.btnGD.setIcon(GDImagePool.iconBtnDir24);
        this.btnGD.setFont(fntButton);
        if (this.lblGD == null) {
            this.lblGD = new JLabel();
        }
        this.lblGD.setFont(fntLabel);
        if (this.btnSave == null) {
            (this.btnSave = new JButton()).addActionListener(new SaveDirListener());
        }
        this.btnSave.setText(GDMsgFormatter.getString(GDMsgFormatter.rbUI, "TXT_GD_SAVE_DIR"));
        this.btnSave.setIcon(GDImagePool.iconBtnDir24);
        this.btnSave.setFont(fntButton);
        if (this.lblSave == null) {
            this.lblSave = new JLabel();
        }
        this.lblSave.setFont(fntLabel);
        if (this.btnExport == null) {
            (this.btnExport = new JButton()).addActionListener(new ExportDirListener());
        }
        this.btnExport.setText(GDMsgFormatter.getString(GDMsgFormatter.rbUI, "TXT_DB_EXPORT_DIR"));
        this.btnExport.setIcon(GDImagePool.iconBtnDir24);
        this.btnExport.setFont(fntButton);
        if (this.lblExport == null) {
            this.lblExport = new JLabel();
        }
        this.lblExport.setFont(fntLabel);
        if (this.lblMod == null) {
            this.lblMod = new JLabel();
        }
        this.lblMod.setText(GDMsgFormatter.getString(GDMsgFormatter.rbUI, "TXT_MOD_SEL"));
        this.lblMod.setFont(fntLabel);
        if (this.cbMod == null) {
            (this.cbMod = new JComboBox<String>()).setModel(this.buildModModel());
            this.cbMod.addActionListener(new ModListener());
        }
        this.cbMod.setFont(fntCombo);
        if (this.lblModStandalone == null) {
            this.lblModStandalone = new JLabel();
        }
        this.lblModStandalone.setText(GDMsgFormatter.getString(GDMsgFormatter.rbUI, "TXT_MOD_STANDALONE"));
        this.lblModStandalone.setFont(fntLabel);
        if (this.cbModStandalone == null) {
            (this.cbModStandalone = new JCheckBox()).setSelected(GDStashFrame.dbConfig.modStandalone);
        }
        this.cbModStandalone.setFont(fntCheck);
        if (this.lblGDLocal == null) {
            this.lblGDLocal = new JLabel();
        }
        this.lblGDLocal.setText(GDMsgFormatter.getString(GDMsgFormatter.rbUI, "TXT_LOCALIZATION"));
        this.lblGDLocal.setFont(fntLabel);
        if (this.cbGDLocal == null) {
            (this.cbGDLocal = new JComboBox<String>()).setModel(this.buildGDLanguageModel());
            this.cbGDLocal.addActionListener(new LocalizationListener());
        }
        this.cbGDLocal.setFont(fntCombo);
        if (this.lblLanguage == null) {
            this.lblLanguage = new JLabel();
        }
        this.lblLanguage.setText(GDMsgFormatter.getString(GDMsgFormatter.rbUI, "TXT_LANG_COUNTRY"));
        this.lblLanguage.setFont(fntLabel);
        if (this.cbLanguage == null) {
            (this.cbLanguage = new JComboBox<String>()).setModel(this.buildLanguageModel());
            this.cbLanguage.addActionListener(new LanguageListener());
        }
        this.cbLanguage.setFont(fntCombo);
        if (this.lblFontSize == null) {
            this.lblFontSize = new JLabel();
        }
        this.lblFontSize.setText(GDMsgFormatter.getString(GDMsgFormatter.rbUI, "TXT_FONT_SIZE"));
        this.lblFontSize.setFont(fntLabel);
        if (this.cbFontSize == null) {
            (this.cbFontSize = new JComboBox<String>()).setModel(this.buildFontSizeModel());
            this.cbFontSize.addActionListener(new FontSizeListener());
        }
        this.cbFontSize.setFont(fntCombo);
        if (this.lblGraphicScale == null) {
            this.lblGraphicScale = new JLabel();
        }
        this.lblGraphicScale.setText(GDMsgFormatter.getString(GDMsgFormatter.rbUI, "TXT_GRAPHIC_SCALE"));
        this.lblGraphicScale.setFont(fntLabel);
        if (this.cbGraphicScale == null) {
            (this.cbGraphicScale = new JComboBox<String>()).setModel(this.buildGraphicScaleModel());
            this.cbGraphicScale.addActionListener(new GraphicScaleListener());
        }
        this.cbGraphicScale.setFont(fntCombo);
        if (this.lblLookNFeel == null) {
            this.lblLookNFeel = new JLabel();
        }
        this.lblLookNFeel.setText(GDMsgFormatter.getString(GDMsgFormatter.rbUI, "TXT_LOOK_FEEL"));
        this.lblLookNFeel.setFont(fntLabel);
        if (this.cbLookNFeel == null) {
            (this.cbLookNFeel = new JComboBox<String>()).setModel(this.buildLnFModel());
            this.cbLookNFeel.addActionListener(new LookNFeelListener());
        }
        this.cbLookNFeel.setFont(fntCombo);
        if (this.lblMinimizeTray == null) {
            this.lblMinimizeTray = new JLabel();
        }
        this.lblMinimizeTray.setText(GDMsgFormatter.getString(GDMsgFormatter.rbUI, "TXT_MINIMIZE_TRAY"));
        this.lblMinimizeTray.setFont(fntLabel);
        if (this.cbMinimizeTray == null) {
            (this.cbMinimizeTray = new JCheckBox()).setSelected(GDStashFrame.iniConfig.sectUI.minimizeToTray);
            this.cbMinimizeTray.addActionListener(new MinimizeTrayListener());
        }
        this.cbMinimizeTray.setFont(fntCheck);
        if (this.cbAllowEdit == null) {
            (this.cbAllowEdit = new JCheckBox()).setSelected(GDStashFrame.iniConfig.sectRestrict.allowEdit);
            this.cbAllowEdit.addActionListener(new EditListener());
        }
        this.cbAllowEdit.setText(GDMsgFormatter.getString(GDMsgFormatter.rbUI, "TXT_ALLOW_EDIT"));
        this.cbAllowEdit.setFont(fntCheck);
        if (this.cbTransSCHC == null) {
            (this.cbTransSCHC = new JCheckBox()).setSelected(GDStashFrame.iniConfig.sectRestrict.transferSCHC);
            this.cbTransSCHC.addActionListener(new HCSCListener());
        }
        this.cbTransSCHC.setText(GDMsgFormatter.getString(GDMsgFormatter.rbUI, "TXT_TRANSFER_SC_HC"));
        this.cbTransSCHC.setFont(fntCheck);
        if (this.cbTransSoul == null) {
            (this.cbTransSoul = new JCheckBox()).setSelected(GDStashFrame.iniConfig.sectRestrict.transferSoulbound);
            this.cbTransSoul.addActionListener(new SoulboundListener());
        }
        this.cbTransSoul.setText(GDMsgFormatter.getString(GDMsgFormatter.rbUI, "TXT_TRANSFER_SOUL"));
        this.cbTransSoul.setFont(fntCheck);
        if (this.cbCompletionAll == null) {
            (this.cbCompletionAll = new JCheckBox()).setSelected(GDStashFrame.iniConfig.sectRestrict.completionAll);
            this.cbCompletionAll.addActionListener(new CompletionListener());
        }
        this.cbCompletionAll.setText(GDMsgFormatter.getString(GDMsgFormatter.rbUI, "TXT_COMPLETE_ALL"));
        this.cbCompletionAll.setToolTipText(GDMsgFormatter.getString(GDMsgFormatter.rbUI, "TIP_COMPLETE_ALL"));
        this.cbCompletionAll.setFont(fntCheck);
        if (this.cbBlacksmithAll == null) {
            (this.cbBlacksmithAll = new JCheckBox()).setSelected(GDStashFrame.iniConfig.sectRestrict.blacksmithAll);
            this.cbBlacksmithAll.addActionListener(new BlacksmithListener());
        }
        this.cbBlacksmithAll.setText(GDMsgFormatter.getString(GDMsgFormatter.rbUI, "TXT_BLACKSMITH_ALL"));
        this.cbBlacksmithAll.setFont(fntCheck);
        if (this.rbCombiValid == null) {
            (this.rbCombiValid = new JRadioButton()).setSelected(GDStashFrame.iniConfig.sectRestrict.affixCombi == 1);
            this.rbCombiValid.addActionListener(new AffixComboListener());
        }
        this.rbCombiValid.setText(GDMsgFormatter.getString(GDMsgFormatter.rbUI, "TXT_AFFIX_VALID"));
        this.rbCombiValid.setToolTipText(GDMsgFormatter.getString(GDMsgFormatter.rbUI, "TIP_AFFIX_VALID"));
        this.rbCombiValid.setFont(fntRadio);
        if (this.rbCombiAllCombos == null) {
            (this.rbCombiAllCombos = new JRadioButton()).setSelected(GDStashFrame.iniConfig.sectRestrict.affixCombi == 2);
            this.rbCombiAllCombos.addActionListener(new AffixComboListener());
        }
        this.rbCombiAllCombos.setText(GDMsgFormatter.getString(GDMsgFormatter.rbUI, "TXT_AFFIX_ALL_COMB"));
        this.rbCombiAllCombos.setToolTipText(GDMsgFormatter.getString(GDMsgFormatter.rbUI, "TIP_AFFIX_ALL_COMB"));
        this.rbCombiAllCombos.setFont(fntRadio);
        if (this.rbCombiAllAffixes == null) {
            (this.rbCombiAllAffixes = new JRadioButton()).setSelected(GDStashFrame.iniConfig.sectRestrict.affixCombi == 3);
            this.rbCombiAllAffixes.addActionListener(new AffixComboListener());
        }
        this.rbCombiAllAffixes.setText(GDMsgFormatter.getString(GDMsgFormatter.rbUI, "TXT_AFFIX_ALL_AFFIX"));
        this.rbCombiAllAffixes.setToolTipText(GDMsgFormatter.getString(GDMsgFormatter.rbUI, "TIP_AFFIX_ALL_AFFIX"));
        this.rbCombiAllAffixes.setFont(fntRadio);
        if (this.lblDBStashMove == null) {
            this.lblDBStashMove = new JLabel();
        }
        this.lblDBStashMove.setText(GDMsgFormatter.getString(GDMsgFormatter.rbUI, "TXT_DB_STASH_TRANS"));
        this.lblDBStashMove.setFont(fntLabel);
        if (this.cbDBStashMove == null) {
            (this.cbDBStashMove = new JComboBox<String>()).addActionListener(new DBStashMoveListener());
        }
        this.cbDBStashMove.setModel(this.buildDBStashMoveModel());
        this.cbDBStashMove.setFont(fntCombo);
    }

    private void initData() {
        DBConfig.reset();
        DBEngineGame.reset();
        DBEnginePlayer.reset();
        DBEngineLevel.reset();
        DBEngineSkillMaster.reset();
        GDStashFrame.readDBConfig(this.frame);
        if (GDStashFrame.dbConfig == null) {
            this.cbModStandalone.setSelected(false);
        } else {
            if (GDStashFrame.iniConfig.sectHistory.lastMod == null || GDStashFrame.iniConfig.sectHistory.lastMod.isEmpty()) {
                GDStashFrame.dbConfig.modStandalone = false;
            }
            this.cbModStandalone.setSelected(GDStashFrame.dbConfig.modStandalone);
            if (GDStashFrame.dbConfig.gddbInit) {
                ItemSetPane.loadSets();
                SkillModifierPane.loadSkills();
                SkillBonusPane.loadSkills();
                ItemSkillPane.loadSkills();
                GDMasteryInfoPane.initStats();
                GDCharMasteryPane.loadMasteries();
                GDCharMasteryImagePane.initStats();
                GDStashFrame.initCraftingAffixes();
                if (this.frame.pnlTransfer != null) {
                    this.frame.pnlTransfer.updateConfig();
                }
                if (this.frame.pnlCharInventory != null) {
                    this.frame.pnlCharInventory.updateConfig();
                }
                if (this.frame.pnlCraft != null) {
                    this.frame.pnlCraft.updateConfig();
                }
                if (this.frame.pnlCharEdit != null) {
                    this.frame.pnlCharEdit.updateConfig();
                }
                if (this.frame.pnlMasteryInfo != null) {
                    this.frame.pnlMasteryInfo.updateConfig();
                }
                if (this.frame.pnlCollection != null) {
                    this.frame.pnlCollection.updateConfig();
                }
            }
        }
        boolean exists = false;
        try {
            exists = GDDBUtil.tableExists("GD_ITEM");
        } catch (SQLException ex) {
            exists = false;
        }
        if (!exists) {
            GDMsgLogger.clear();
            return;
        }
        this.frame.refresh();
        this.frame.checkTabs();
    }

    private JPanel buildMainPanel() {
        final JPanel panel = new JPanel();
        GroupLayout layout = null;
        GroupLayout.SequentialGroup hGroup = null;
        GroupLayout.SequentialGroup vGroup = null;
        final JPanel pnlConfig = this.buildConfigPanel();
        layout = new GroupLayout(panel);
        panel.setLayout(layout);
        layout.setAutoCreateGaps(true);
        layout.setAutoCreateContainerGaps(true);
        hGroup = layout.createSequentialGroup();
        hGroup.addGroup(layout.createParallelGroup().addComponent(pnlConfig).addComponent(this.btnConfig).addComponent(this.btnDBImport));
        layout.setHorizontalGroup(hGroup);
        vGroup = layout.createSequentialGroup();
        vGroup.addGroup(layout.createParallelGroup().addComponent(pnlConfig)).addGroup(layout.createParallelGroup().addComponent(this.btnConfig)).addGroup(layout.createParallelGroup().addComponent(this.btnDBImport));
        layout.setVerticalGroup(vGroup);
        layout.linkSize(0, pnlConfig, this.btnConfig);
        layout.linkSize(0, pnlConfig, this.btnDBImport);
        layout.linkSize(1, this.btnConfig, this.btnDBImport);
        return panel;
    }

    private JPanel buildConfigPanel() {
        GroupLayout layout = null;
        GroupLayout.SequentialGroup hGroup = null;
        GroupLayout.SequentialGroup vGroup = null;
        final JPanel panel = new JPanel();
        final JPanel pnlGeneral = this.buildGeneralPanel();
        final JPanel pnlRestrict = this.buildRestrictPanel();
        layout = new GroupLayout(panel);
        panel.setLayout(layout);
        layout.setAutoCreateGaps(true);
        layout.setAutoCreateContainerGaps(true);
        hGroup = layout.createSequentialGroup();
        hGroup.addGroup(layout.createParallelGroup().addComponent(pnlGeneral).addComponent(pnlRestrict));
        layout.setHorizontalGroup(hGroup);
        vGroup = layout.createSequentialGroup();
        vGroup.addGroup(layout.createParallelGroup().addComponent(pnlGeneral)).addGroup(layout.createParallelGroup().addComponent(pnlRestrict));
        layout.setVerticalGroup(vGroup);
        layout.linkSize(0, pnlGeneral, pnlRestrict);
        return panel;
    }

    private JPanel buildGeneralPanel() {
        GroupLayout layout = null;
        GroupLayout.SequentialGroup hGroup = null;
        GroupLayout.SequentialGroup vGroup = null;
        final JPanel panel = new JPanel();
        this.strGD = GDStashFrame.iniConfig.sectDir.gdPath;
        if (this.strGD == null) {
            this.lblGD.setText("");
        } else {
            this.lblGD.setText(this.strGD);
            this.dirGD = new File(this.strGD);
        }
        this.strSave = GDStashFrame.iniConfig.sectDir.savePath;
        if (this.strSave == null) {
            this.lblSave.setText("");
        } else {
            this.lblSave.setText(this.strSave);
            this.dirSave = new File(this.strSave);
        }
        this.strExport = GDStashFrame.iniConfig.sectDir.exportPath;
        if (this.strExport == null || this.strExport.equals("")) {
            this.strExport = GDConstants.USER_DIR;
        }
        this.lblExport.setText(this.strExport);
        this.dirExport = new File(this.strExport);
        final DocumentFilter filter = new StrLenDocFilter(2);
        final AbstractDocument doc = null;
        layout = new GroupLayout(panel);
        panel.setLayout(layout);
        layout.setAutoCreateGaps(true);
        layout.setAutoCreateContainerGaps(true);
        hGroup = layout.createSequentialGroup();
        hGroup.addGroup(layout.createParallelGroup().addComponent(this.btnHelp).addComponent(this.btnGD).addComponent(this.btnSave).addComponent(this.lblGDLocal).addComponent(this.lblMod).addComponent(this.lblModStandalone).addComponent(this.lblLanguage).addComponent(this.lblLookNFeel).addComponent(this.lblMinimizeTray).addComponent(this.lblFontSize).addComponent(this.lblGraphicScale)).addGroup(layout.createParallelGroup().addComponent(this.lblGD).addComponent(this.lblSave).addComponent(this.cbGDLocal).addComponent(this.cbMod).addComponent(this.cbModStandalone).addComponent(this.cbLanguage).addComponent(this.cbLookNFeel).addComponent(this.cbMinimizeTray).addComponent(this.cbFontSize).addComponent(this.cbGraphicScale));
        layout.setHorizontalGroup(hGroup);
        vGroup = layout.createSequentialGroup();
        vGroup.addGroup(layout.createParallelGroup().addComponent(this.btnHelp)).addGroup(layout.createParallelGroup().addComponent(this.btnGD).addComponent(this.lblGD)).addGroup(layout.createParallelGroup().addComponent(this.btnSave).addComponent(this.lblSave)).addGroup(layout.createParallelGroup().addComponent(this.lblGDLocal).addComponent(this.cbGDLocal)).addGroup(layout.createParallelGroup().addComponent(this.lblMod).addComponent(this.cbMod)).addGroup(layout.createParallelGroup().addComponent(this.lblModStandalone).addComponent(this.cbModStandalone)).addGroup(layout.createParallelGroup().addComponent(this.lblLanguage).addComponent(this.cbLanguage)).addGroup(layout.createParallelGroup().addComponent(this.lblLookNFeel).addComponent(this.cbLookNFeel)).addGroup(layout.createParallelGroup().addComponent(this.lblMinimizeTray).addComponent(this.cbMinimizeTray)).addGroup(layout.createParallelGroup().addComponent(this.lblFontSize).addComponent(this.cbFontSize)).addGroup(layout.createParallelGroup().addComponent(this.lblGraphicScale).addComponent(this.cbGraphicScale));
        layout.setVerticalGroup(vGroup);
        layout.linkSize(0, this.btnGD, this.btnHelp);
        layout.linkSize(0, this.btnGD, this.btnSave);
        layout.linkSize(0, this.btnGD, this.lblGDLocal);
        layout.linkSize(0, this.btnGD, this.lblMod);
        layout.linkSize(0, this.btnGD, this.lblModStandalone);
        layout.linkSize(0, this.btnGD, this.lblLanguage);
        layout.linkSize(0, this.btnGD, this.lblLookNFeel);
        layout.linkSize(0, this.btnGD, this.lblMinimizeTray);
        layout.linkSize(0, this.btnGD, this.lblFontSize);
        layout.linkSize(0, this.btnGD, this.lblGraphicScale);
        layout.linkSize(0, this.btnGD, this.lblGD);
        layout.linkSize(0, this.btnGD, this.lblSave);
        layout.linkSize(0, this.btnGD, this.cbGDLocal);
        layout.linkSize(0, this.btnGD, this.cbMod);
        layout.linkSize(0, this.btnGD, this.cbModStandalone);
        layout.linkSize(0, this.btnGD, this.cbLanguage);
        layout.linkSize(0, this.btnGD, this.cbLookNFeel);
        layout.linkSize(0, this.btnGD, this.cbMinimizeTray);
        layout.linkSize(0, this.btnGD, this.cbFontSize);
        layout.linkSize(0, this.btnGD, this.cbGraphicScale);
        layout.linkSize(1, this.btnGD, this.btnHelp);
        layout.linkSize(1, this.btnGD, this.btnSave);
        layout.linkSize(1, this.btnGD, this.lblGDLocal);
        layout.linkSize(1, this.btnGD, this.lblMod);
        layout.linkSize(1, this.btnGD, this.lblModStandalone);
        layout.linkSize(1, this.btnGD, this.lblLanguage);
        layout.linkSize(1, this.btnGD, this.lblLookNFeel);
        layout.linkSize(1, this.btnGD, this.lblMinimizeTray);
        layout.linkSize(1, this.btnGD, this.lblFontSize);
        layout.linkSize(1, this.btnGD, this.lblGraphicScale);
        layout.linkSize(1, this.btnGD, this.lblGD);
        layout.linkSize(1, this.btnGD, this.lblSave);
        layout.linkSize(1, this.btnGD, this.cbGDLocal);
        layout.linkSize(1, this.btnGD, this.cbMod);
        layout.linkSize(1, this.btnGD, this.cbModStandalone);
        layout.linkSize(1, this.btnGD, this.cbLanguage);
        layout.linkSize(1, this.btnGD, this.cbLookNFeel);
        layout.linkSize(1, this.btnGD, this.cbMinimizeTray);
        layout.linkSize(1, this.btnGD, this.cbFontSize);
        layout.linkSize(1, this.btnGD, this.cbGraphicScale);
        panel.setBorder(this.brdGeneral);
        return panel;
    }

    private JPanel buildRestrictPanel() {
        GroupLayout layout = null;
        GroupLayout.SequentialGroup hGroup = null;
        GroupLayout.SequentialGroup vGroup = null;
        final JPanel panel = new JPanel();
        final JPanel pnlMisc = this.buildMiscRestrictPanel();
        final JPanel pnlAffixCombi = this.buildAffixCombiPanel();
        final JPanel pnlDBStashMove = this.buildDBStashMovePanel();
        layout = new GroupLayout(panel);
        panel.setLayout(layout);
        layout.setAutoCreateGaps(true);
        layout.setAutoCreateContainerGaps(true);
        hGroup = layout.createSequentialGroup();
        hGroup.addGroup(layout.createParallelGroup().addComponent(pnlMisc).addComponent(pnlAffixCombi).addComponent(pnlDBStashMove));
        layout.setHorizontalGroup(hGroup);
        vGroup = layout.createSequentialGroup();
        vGroup.addComponent(pnlMisc).addComponent(pnlAffixCombi).addComponent(pnlDBStashMove);
        layout.setVerticalGroup(vGroup);
        layout.linkSize(0, pnlMisc, pnlAffixCombi);
        layout.linkSize(0, pnlMisc, pnlDBStashMove);
        panel.setBorder(this.brdRestrict);
        return panel;
    }

    private JPanel buildMiscRestrictPanel() {
        GroupLayout layout = null;
        GroupLayout.SequentialGroup hGroup = null;
        GroupLayout.SequentialGroup vGroup = null;
        final JPanel panel = new JPanel();
        layout = new GroupLayout(panel);
        panel.setLayout(layout);
        layout.setAutoCreateGaps(true);
        layout.setAutoCreateContainerGaps(true);
        hGroup = layout.createSequentialGroup();
        hGroup.addGroup(layout.createParallelGroup().addComponent(this.cbAllowEdit).addComponent(this.cbTransSCHC).addComponent(this.cbTransSoul).addComponent(this.cbCompletionAll).addComponent(this.cbBlacksmithAll));
        layout.setHorizontalGroup(hGroup);
        vGroup = layout.createSequentialGroup();
        vGroup.addGroup(layout.createParallelGroup().addComponent(this.cbAllowEdit)).addGroup(layout.createParallelGroup().addComponent(this.cbTransSCHC)).addGroup(layout.createParallelGroup().addComponent(this.cbTransSoul)).addGroup(layout.createParallelGroup().addComponent(this.cbCompletionAll)).addGroup(layout.createParallelGroup().addComponent(this.cbBlacksmithAll));
        layout.setVerticalGroup(vGroup);
        layout.linkSize(0, this.cbAllowEdit, this.cbTransSCHC);
        layout.linkSize(0, this.cbAllowEdit, this.cbTransSoul);
        layout.linkSize(0, this.cbAllowEdit, this.cbCompletionAll);
        layout.linkSize(0, this.cbAllowEdit, this.cbBlacksmithAll);
        layout.linkSize(1, this.cbAllowEdit, this.cbTransSCHC);
        layout.linkSize(1, this.cbAllowEdit, this.cbTransSoul);
        layout.linkSize(1, this.cbAllowEdit, this.cbCompletionAll);
        layout.linkSize(1, this.cbAllowEdit, this.cbBlacksmithAll);
        return panel;
    }

    private JPanel buildAffixCombiPanel() {
        GroupLayout layout = null;
        GroupLayout.SequentialGroup hGroup = null;
        GroupLayout.SequentialGroup vGroup = null;
        final JPanel panel = new JPanel();
        (this.bgCombi = new ButtonGroup()).add(this.rbCombiValid);
        this.bgCombi.add(this.rbCombiAllCombos);
        this.bgCombi.add(this.rbCombiAllAffixes);
        layout = new GroupLayout(panel);
        panel.setLayout(layout);
        layout.setAutoCreateGaps(true);
        layout.setAutoCreateContainerGaps(true);
        hGroup = layout.createSequentialGroup();
        hGroup.addGroup(layout.createParallelGroup().addComponent(this.rbCombiValid).addComponent(this.rbCombiAllCombos).addComponent(this.rbCombiAllAffixes));
        layout.setHorizontalGroup(hGroup);
        vGroup = layout.createSequentialGroup();
        vGroup.addGroup(layout.createParallelGroup().addComponent(this.rbCombiValid)).addGroup(layout.createParallelGroup().addComponent(this.rbCombiAllCombos)).addGroup(layout.createParallelGroup().addComponent(this.rbCombiAllAffixes));
        layout.setVerticalGroup(vGroup);
        layout.linkSize(0, this.rbCombiValid, this.rbCombiAllCombos);
        layout.linkSize(0, this.rbCombiValid, this.rbCombiAllAffixes);
        layout.linkSize(1, this.rbCombiValid, this.rbCombiAllCombos);
        layout.linkSize(1, this.rbCombiValid, this.rbCombiAllAffixes);
        panel.setBorder(this.brdCombi);
        return panel;
    }

    private JPanel buildDBStashMovePanel() {
        GroupLayout layout = null;
        GroupLayout.SequentialGroup hGroup = null;
        GroupLayout.SequentialGroup vGroup = null;
        final JPanel panel = new JPanel();
        layout = new GroupLayout(panel);
        panel.setLayout(layout);
        layout.setAutoCreateGaps(true);
        layout.setAutoCreateContainerGaps(true);
        hGroup = layout.createSequentialGroup();
        hGroup.addGroup(layout.createParallelGroup().addComponent(this.lblDBStashMove)).addGroup(layout.createParallelGroup().addComponent(this.cbDBStashMove));
        layout.setHorizontalGroup(hGroup);
        vGroup = layout.createSequentialGroup();
        vGroup.addGroup(layout.createParallelGroup().addComponent(this.lblDBStashMove).addComponent(this.cbDBStashMove));
        layout.setVerticalGroup(vGroup);
        layout.linkSize(0, this.lblDBStashMove, this.cbDBStashMove);
        layout.linkSize(1, this.lblDBStashMove, this.cbDBStashMove);
        return panel;
    }

    private ComboBoxModel<String> buildLnFModel() {
        final DefaultComboBoxModel<String> model = new DefaultComboBoxModel<String>();
        final UIManager.LookAndFeelInfo[] info = UIManager.getInstalledLookAndFeels();
        for (int i = 0; i < info.length; ++i) {
            final String s = info[i].getName();
            model.addElement(s);
        }
        final DefaultComboBoxModel<String> defaultComboBoxModel = model;
        final GDStashFrame frame = this.frame;
        defaultComboBoxModel.setSelectedItem(GDStashFrame.iniConfig.sectUI.lookNFeel);
        return model;
    }

    private ComboBoxModel<String> buildFontSizeModel() {
        final DefaultComboBoxModel<String> model = new DefaultComboBoxModel<String>();
        model.addElement("8");
        model.addElement("10");
        model.addElement("12");
        model.addElement("14");
        model.addElement("16");
        model.addElement("18");
        model.addElement("20");
        model.addElement("24");
        final DefaultComboBoxModel<String> defaultComboBoxModel = model;
        final GDStashFrame frame = this.frame;
        defaultComboBoxModel.setSelectedItem(Integer.toString(GDStashFrame.iniConfig.sectUI.fontSize));
        return model;
    }

    private ComboBoxModel<String> buildGraphicScaleModel() {
        final DefaultComboBoxModel<String> model = new DefaultComboBoxModel<String>();
        model.addElement("50%");
        model.addElement("75%");
        model.addElement("100%");
        model.addElement("125%");
        model.addElement("150%");
        model.addElement("175%");
        model.addElement("200%");
        final StringBuilder sb = new StringBuilder();
        final GDStashFrame frame = this.frame;
        final String s = sb.append(Integer.toString(GDStashFrame.iniConfig.sectUI.graphicScale)).append("%").toString();
        model.setSelectedItem(s);
        return model;
    }

    private ComboBoxModel<String> buildDBStashMoveModel() {
        final DefaultComboBoxModel<String> model = new DefaultComboBoxModel<String>();
        final String sCopy = GDMsgFormatter.getString(GDMsgFormatter.rbUI, "TXT_DB_TRANS_COPY");
        final String sMove = GDMsgFormatter.getString(GDMsgFormatter.rbUI, "TXT_DB_TRANS_MOVE");
        model.addElement(sCopy);
        model.addElement(sMove);
        if (GDStashFrame.iniConfig.sectRestrict.dbStashMove) {
            model.setSelectedItem(sMove);
        } else {
            model.setSelectedItem(sCopy);
        }
        return model;
    }

    private ComboBoxModel<String> buildModModel() {
        final DefaultComboBoxModel<String> model = new DefaultComboBoxModel<String>();
        model.addElement("");
        if (this.strGD == null || this.strGD.equals("")) {
            return model;
        }
        final File dir = new File(this.strGD + GDConstants.FILE_SEPARATOR + "mods");
        if (!dir.exists()) {
            return model;
        }
        if (!dir.isDirectory()) {
            return model;
        }
        final int len = this.strGD.length() + 6;
        final File[] files = dir.listFiles();
        for (int i = 0; i < files.length; ++i) {
            if (files[i].isDirectory()) {
                try {
                    String s = files[i].getCanonicalPath();
                    if (s.length() > len) {
                        s = s.substring(len);
                    }
                    model.addElement(s);
                } catch (IOException ex) {
                }
            }
        }
        if (GDStashFrame.iniConfig.sectHistory.lastMod != null) {
            model.setSelectedItem(GDStashFrame.iniConfig.sectHistory.lastMod);
        }
        return model;
    }

    private ComboBoxModel<String> buildGDLanguageModel() {
        final DefaultComboBoxModel<String> model = new DefaultComboBoxModel<String>();
        model.addElement("");
        if (this.strGD == null || this.strGD.equals("")) {
            return model;
        }
        final File locDir = new File(this.strGD + GDConstants.FILE_SEPARATOR + "localization");
        final File arcDir = new File(this.strGD + GDConstants.FILE_SEPARATOR + "resources");
        if (arcDir.exists() && arcDir.isDirectory()) {
            final String[] files = arcDir.list();
            for (int i = 0; i < files.length; ++i) {
                if (files[i].endsWith(".arc")) {
                    if (files[i].startsWith("Text_")) {
                        model.addElement(files[i]);
                    }
                }
            }
        }
        if (locDir.exists() && locDir.isDirectory()) {
            final String[] files = locDir.list();
            for (int i = 0; i < files.length; ++i) {
                if (files[i].endsWith(".zip")) {
                    model.addElement(files[i]);
                }
            }
        }
        if (GDStashFrame.dbConfig.gdLocal != null) {
            model.setSelectedItem(GDStashFrame.dbConfig.gdLocal);
        }
        return model;
    }

    private ComboBoxModel<String> buildLanguageModel() {
        final DefaultComboBoxModel<String> model = new DefaultComboBoxModel<String>();
        final String defLang = "English";
        model.addElement(defLang);
        final File dir = new File(GDConstants.USER_DIR);
        if (!dir.exists()) {
            return model;
        }
        if (!dir.isDirectory()) {
            return model;
        }
        final String[] files = dir.list();
        for (int i = 0; i < files.length; ++i) {
            if (files[i].startsWith("UI")) {
                if (files[i].endsWith(".properties")) {
                    final int pos1 = files[i].indexOf("_");
                    if (pos1 != -1) {
                        final int pos2 = files[i].indexOf(".properties");
                        if (pos2 != -1) {
                            final String lang = files[i].substring(pos1 + 1, pos2);
                            if (!lang.equals(defLang)) {
                                model.addElement(lang);
                            }
                        }
                    }
                }
            }
        }
        if (GDStashFrame.iniConfig.sectUI.language != null) {
            final String locale = GDStashFrame.iniConfig.sectUI.language;
            model.setSelectedItem(locale);
        } else {
            model.setSelectedItem(defLang);
        }
        return model;
    }

    private boolean isCorrectDirs() {
        return this.isCorrectInstallDir(this.strGD) && this.isCorrectSaveDir(this.strSave);
    }

    private boolean isCorrectInstallDir(final String dir) {
        final String s = dir + GDConstants.FILE_SEPARATOR + "database" + GDConstants.FILE_SEPARATOR + "database.arz";
        final File f = new File(s);
        return f.exists();
    }

    private boolean isCorrectSaveDir(final String dir) {
        final String s1 = dir + GDConstants.FILE_SEPARATOR + "transfer.gst";
        final String s2 = dir + GDConstants.FILE_SEPARATOR + "transfer.gsh";
        final File f1 = new File(s1);
        final File f2 = new File(s2);
        if (f1.exists() || f2.exists()) {
            return true;
        }
        final String s3 = dir.substring(dir.length() - 4);
        if (!s3.equals("save")) {
            return false;
        }
        final String s4 = dir + GDConstants.FILE_SEPARATOR + "main";
        final String s5 = dir + GDConstants.FILE_SEPARATOR + "user";
        final File f3 = new File(s4);
        final File f4 = new File(s5);
        return (f3.exists() && f3.isDirectory()) || (f4.exists() && f4.isDirectory());
    }

    public String getSaveDir() {
        if (!this.isCorrectSaveDir(this.strSave)) {
            return null;
        }
        return this.strSave;
    }

    public String getSelectedMod() {
        final String mod = (String) this.cbMod.getSelectedItem();
        if (mod == null) {
            return null;
        }
        if (mod.length() == 0) {
            return null;
        }
        return mod;
    }

    private String getModDatabase() {
        final String mod = (String) this.cbMod.getSelectedItem();
        if (mod == null) {
            return null;
        }
        if (mod.length() == 0) {
            return null;
        }
        String db = null;
        final String dir = this.strGD + GDConstants.FILE_SEPARATOR + "mods" + GDConstants.FILE_SEPARATOR + mod + GDConstants.FILE_SEPARATOR + "database";
        final File file = new File(dir);
        if (file.isDirectory()) {
            final File[] files = file.listFiles();
            for (int i = 0; i < files.length; ++i) {
                try {
                    final String s = files[i].getCanonicalPath();
                    if (s.toUpperCase(GDConstants.LOCALE_US).endsWith(".ARZ")) {
                        db = s;
                        break;
                    }
                } catch (IOException ex) {
                }
            }
        }
        return db;
    }

    private List<ARCList.ARCFile> getImportARCFileList() {
        final List<ARCList.ARCFile> arcs = new LinkedList<ARCList.ARCFile>();
        ARCList.ARCFile arcFile = null;
        String fn = null;
        if (GDStashFrame.expansionFangsOfAsterkarn) {
            fn = this.strGD + GDConstants.FILE_SEPARATOR + "gdx3" + GDConstants.FILE_SEPARATOR + "resources" + GDConstants.FILE_SEPARATOR + "Items.arc";
            arcFile = new ARCList.ARCFile(ARCDecompress.FileModule.FG, fn);
            arcs.add(arcFile);
        }
        if (GDStashFrame.expansionForgottenGods) {
            fn = this.strGD + GDConstants.FILE_SEPARATOR + "gdx2" + GDConstants.FILE_SEPARATOR + "resources" + GDConstants.FILE_SEPARATOR + "Items.arc";
            arcFile = new ARCList.ARCFile(ARCDecompress.FileModule.FG, fn);
            arcs.add(arcFile);
        }
        if (GDStashFrame.expansionAshesOfMalmouth) {
            fn = this.strGD + GDConstants.FILE_SEPARATOR + "gdx1" + GDConstants.FILE_SEPARATOR + "resources" + GDConstants.FILE_SEPARATOR + "Items.arc";
            arcFile = new ARCList.ARCFile(ARCDecompress.FileModule.AoM, fn);
            arcs.add(arcFile);
        }
        fn = this.strGD + GDConstants.FILE_SEPARATOR + "resources" + GDConstants.FILE_SEPARATOR + "Items.arc";
        arcFile = new ARCList.ARCFile(ARCDecompress.FileModule.GD, fn);
        arcs.add(arcFile);
        if (GDStashFrame.expansionFangsOfAsterkarn) {
            fn = this.strGD + GDConstants.FILE_SEPARATOR + "gdx3" + GDConstants.FILE_SEPARATOR + "resources" + GDConstants.FILE_SEPARATOR + "UI.arc";
            arcFile = new ARCList.ARCFile(ARCDecompress.FileModule.FG, fn);
            arcs.add(arcFile);
        }
        if (GDStashFrame.expansionForgottenGods) {
            fn = this.strGD + GDConstants.FILE_SEPARATOR + "gdx2" + GDConstants.FILE_SEPARATOR + "resources" + GDConstants.FILE_SEPARATOR + "UI.arc";
            arcFile = new ARCList.ARCFile(ARCDecompress.FileModule.FG, fn);
            arcs.add(arcFile);
        }
        if (GDStashFrame.expansionAshesOfMalmouth) {
            fn = this.strGD + GDConstants.FILE_SEPARATOR + "gdx1" + GDConstants.FILE_SEPARATOR + "resources" + GDConstants.FILE_SEPARATOR + "UI.arc";
            arcFile = new ARCList.ARCFile(ARCDecompress.FileModule.AoM, fn);
            arcs.add(arcFile);
        }
        fn = this.strGD + GDConstants.FILE_SEPARATOR + "resources" + GDConstants.FILE_SEPARATOR + "UI.arc";
        arcFile = new ARCList.ARCFile(ARCDecompress.FileModule.GD, fn);
        arcs.add(arcFile);
        if (GDStashFrame.expansionForgottenGods) {
            fn = this.strGD + GDConstants.FILE_SEPARATOR + "gdx2" + GDConstants.FILE_SEPARATOR + "resources" + GDConstants.FILE_SEPARATOR + "System.arc";
            arcFile = new ARCList.ARCFile(ARCDecompress.FileModule.AoM, fn);
            arcs.add(arcFile);
        }
        if (GDStashFrame.expansionAshesOfMalmouth) {
            fn = this.strGD + GDConstants.FILE_SEPARATOR + "gdx1" + GDConstants.FILE_SEPARATOR + "resources" + GDConstants.FILE_SEPARATOR + "Level Art.arc";
            arcFile = new ARCList.ARCFile(ARCDecompress.FileModule.AoM, fn);
            arcs.add(arcFile);
        }
        if (GDStashFrame.dbConfig.gdLocal != null && !GDStashFrame.dbConfig.gdLocal.equals("") && !GDStashFrame.dbConfig.gdLocal.toUpperCase(GDConstants.LOCALE_US).equals("TEXT_EN.ARC")) {
            if (GDStashFrame.dbConfig.gdLocal.toUpperCase(GDConstants.LOCALE_US).endsWith(".ARC")) {
                fn = this.strGD + GDConstants.FILE_SEPARATOR + "resources" + GDConstants.FILE_SEPARATOR + GDStashFrame.dbConfig.gdLocal;
            } else {
                fn = this.strGD + GDConstants.FILE_SEPARATOR + "localization" + GDConstants.FILE_SEPARATOR + GDStashFrame.dbConfig.gdLocal;
            }
            arcFile = new ARCList.ARCFile(ARCDecompress.FileModule.GD, fn);
            arcs.add(arcFile);
        } else {
            if (GDStashFrame.expansionFangsOfAsterkarn) {
                fn = this.strGD + GDConstants.FILE_SEPARATOR + "gdx3" + GDConstants.FILE_SEPARATOR + "resources" + GDConstants.FILE_SEPARATOR + "Text_EN.arc";
                arcFile = new ARCList.ARCFile(ARCDecompress.FileModule.FG, fn);
                arcs.add(arcFile);
            }
            if (GDStashFrame.expansionForgottenGods) {
                fn = this.strGD + GDConstants.FILE_SEPARATOR + "gdx2" + GDConstants.FILE_SEPARATOR + "resources" + GDConstants.FILE_SEPARATOR + "Text_EN.arc";
                arcFile = new ARCList.ARCFile(ARCDecompress.FileModule.FG, fn);
                arcs.add(arcFile);
            }
            if (GDStashFrame.expansionAshesOfMalmouth) {
                fn = this.strGD + GDConstants.FILE_SEPARATOR + "gdx1" + GDConstants.FILE_SEPARATOR + "resources" + GDConstants.FILE_SEPARATOR + "Text_EN.arc";
                arcFile = new ARCList.ARCFile(ARCDecompress.FileModule.AoM, fn);
                arcs.add(arcFile);
            }
            fn = this.strGD + GDConstants.FILE_SEPARATOR + "resources" + GDConstants.FILE_SEPARATOR + "Text_EN.arc";
            arcFile = new ARCList.ARCFile(ARCDecompress.FileModule.GD, fn);
            arcs.add(arcFile);
        }
        return arcs;
    }

    private ARCList getImportTextARCList() {
        final String mod = (String) this.cbMod.getSelectedItem();
        String dirMod = null;
        if (mod != null && !mod.isEmpty()) {
            dirMod = this.strGD + GDConstants.FILE_SEPARATOR + "mods" + GDConstants.FILE_SEPARATOR + mod + GDConstants.FILE_SEPARATOR + "resources";
        }
        final List<ARCList.ARCFile> arcs = this.getImportARCFileList();
        final ARCList list = new ARCList(dirMod, arcs, ARCList.ListType.Text);
        return list;
    }

    private ARCList getImportImageARCList() {
        final String mod = (String) this.cbMod.getSelectedItem();
        String dirMod = null;
        if (mod != null && !mod.isEmpty()) {
            dirMod = this.strGD + GDConstants.FILE_SEPARATOR + "mods" + GDConstants.FILE_SEPARATOR + mod + GDConstants.FILE_SEPARATOR + "resources";
        }
        final List<ARCList.ARCFile> arcs = this.getImportARCFileList();
        final ARCList list = new ARCList(dirMod, arcs, ARCList.ListType.Image);
        return list;
    }

    private ARCList getExportARCList() {
        final String mod = (String) this.cbMod.getSelectedItem();
        String dirMod = null;
        if (mod != null && !mod.isEmpty()) {
            dirMod = this.strGD + GDConstants.FILE_SEPARATOR + "mods" + GDConstants.FILE_SEPARATOR + mod + GDConstants.FILE_SEPARATOR + "resources";
        }
        final List<ARCList.ARCFile> arcs = new LinkedList<ARCList.ARCFile>();
        ARCList.ARCFile arcFile = null;
        String fn = null;
        if (GDStashFrame.expansionForgottenGods) {
            fn = this.strGD + GDConstants.FILE_SEPARATOR + "gdx2" + GDConstants.FILE_SEPARATOR + "resources" + GDConstants.FILE_SEPARATOR + "Items.arc";
            arcFile = new ARCList.ARCFile(ARCDecompress.FileModule.FG, fn);
            arcs.add(arcFile);
        }
        if (GDStashFrame.expansionAshesOfMalmouth) {
            fn = this.strGD + GDConstants.FILE_SEPARATOR + "gdx1" + GDConstants.FILE_SEPARATOR + "resources" + GDConstants.FILE_SEPARATOR + "Items.arc";
            arcFile = new ARCList.ARCFile(ARCDecompress.FileModule.AoM, fn);
            arcs.add(arcFile);
            fn = this.strGD + GDConstants.FILE_SEPARATOR + "gdx1" + GDConstants.FILE_SEPARATOR + "resources" + GDConstants.FILE_SEPARATOR + "UI.arc";
            arcFile = new ARCList.ARCFile(ARCDecompress.FileModule.AoM, fn);
            arcs.add(arcFile);
            fn = this.strGD + GDConstants.FILE_SEPARATOR + "gdx1" + GDConstants.FILE_SEPARATOR + "resources" + GDConstants.FILE_SEPARATOR + "Scripts.arc";
            arcFile = new ARCList.ARCFile(ARCDecompress.FileModule.AoM, fn);
            arcs.add(arcFile);
        }
        fn = this.strGD + GDConstants.FILE_SEPARATOR + "resources" + GDConstants.FILE_SEPARATOR + "Items.arc";
        arcFile = new ARCList.ARCFile(ARCDecompress.FileModule.GD, fn);
        arcs.add(arcFile);
        fn = this.strGD + GDConstants.FILE_SEPARATOR + "resources" + GDConstants.FILE_SEPARATOR + "UI.arc";
        arcFile = new ARCList.ARCFile(ARCDecompress.FileModule.GD, fn);
        arcs.add(arcFile);
        fn = this.strGD + GDConstants.FILE_SEPARATOR + "resources" + GDConstants.FILE_SEPARATOR + "Scripts.arc";
        arcFile = new ARCList.ARCFile(ARCDecompress.FileModule.GD, fn);
        arcs.add(arcFile);
        if (GDStashFrame.dbConfig.gdLocal != null && !GDStashFrame.dbConfig.gdLocal.equals("")) {
            fn = this.strGD + GDConstants.FILE_SEPARATOR + "localization" + GDConstants.FILE_SEPARATOR + GDStashFrame.dbConfig.gdLocal;
            arcFile = new ARCList.ARCFile(ARCDecompress.FileModule.GD, fn);
            arcs.add(arcFile);
        } else {
            if (GDStashFrame.expansionForgottenGods) {
                fn = this.strGD + GDConstants.FILE_SEPARATOR + "gdx2" + GDConstants.FILE_SEPARATOR + "resources" + GDConstants.FILE_SEPARATOR + "Text_EN.arc";
                arcFile = new ARCList.ARCFile(ARCDecompress.FileModule.FG, fn);
                arcs.add(arcFile);
            }
            if (GDStashFrame.expansionAshesOfMalmouth) {
                fn = this.strGD + GDConstants.FILE_SEPARATOR + "gdx1" + GDConstants.FILE_SEPARATOR + "resources" + GDConstants.FILE_SEPARATOR + "Text_EN.arc";
                arcFile = new ARCList.ARCFile(ARCDecompress.FileModule.AoM, fn);
                arcs.add(arcFile);
            }
            fn = this.strGD + GDConstants.FILE_SEPARATOR + "resources" + GDConstants.FILE_SEPARATOR + "Text_EN.arc";
            arcFile = new ARCList.ARCFile(ARCDecompress.FileModule.GD, fn);
            arcs.add(arcFile);
        }
        final ARCList list = new ARCList(dirMod, arcs, ARCList.ListType.Mixed);
        return list;
    }

    private class DBImportWorker extends SwingWorker<Void, Void> {
        private GDProgressDialog prog;
        private boolean completed;

        public DBImportWorker() {
            GDConfigPane.this.setCursor(Cursor.getPredefinedCursor(3));
            this.prog = new GDProgressDialog(GDConfigPane.this.frame, GDMsgFormatter.getString(GDMsgFormatter.rbUI, "PROG_LOAD_ARCS"));
            this.completed = false;
            this.addPropertyChangeListener(new PropertyChangeListener() {
                @Override
                public void propertyChange(final PropertyChangeEvent e) {
                    if (e.getPropertyName().equals("progress")) {
                        final int i = (int) e.getNewValue();
                        if (i < 10) {
                            DBImportWorker.this.prog.setText(GDMsgFormatter.getString(GDMsgFormatter.rbUI, "PROG_LOAD_ARCS"));
                        }
                        if (i >= 10 && i < 20) {
                            DBImportWorker.this.prog.setText(GDMsgFormatter.getString(GDMsgFormatter.rbUI, "PROC_IMP_MOD"));
                        }
                        if (i >= 20 && i < 25) {
                            DBImportWorker.this.prog.setText(GDMsgFormatter.getString(GDMsgFormatter.rbUI, "PROG_DEC_GDX3_ARZ"));
                        }
                        if (i >= 25 && i < 30) {
                            DBImportWorker.this.prog.setText(GDMsgFormatter.getString(GDMsgFormatter.rbUI, "PROC_IMP_GDX3_ARZ"));
                        }
                        if (i >= 30 && i < 35) {
                            DBImportWorker.this.prog.setText(GDMsgFormatter.getString(GDMsgFormatter.rbUI, "PROG_DEC_GDX2_ARZ"));
                        }
                        if (i >= 35 && i < 40) {
                            DBImportWorker.this.prog.setText(GDMsgFormatter.getString(GDMsgFormatter.rbUI, "PROC_IMP_GDX2_ARZ"));
                        }
                        if (i >= 40 && i < 50) {
                            DBImportWorker.this.prog.setText(GDMsgFormatter.getString(GDMsgFormatter.rbUI, "PROG_DEC_GDX1_ARZ"));
                        }
                        if (i >= 50 && i < 60) {
                            DBImportWorker.this.prog.setText(GDMsgFormatter.getString(GDMsgFormatter.rbUI, "PROC_IMP_GDX1_ARZ"));
                        }
                        if (i >= 60 && i < 70) {
                            DBImportWorker.this.prog.setText(GDMsgFormatter.getString(GDMsgFormatter.rbUI, "PROG_DEC_DB_ARZ"));
                        }
                        if (i >= 70 && i < 80) {
                            DBImportWorker.this.prog.setText(GDMsgFormatter.getString(GDMsgFormatter.rbUI, "PROC_IMP_DB_ARZ"));
                        }
                        if (i >= 80 && i < 90) {
                            DBImportWorker.this.prog.setText(GDMsgFormatter.getString(GDMsgFormatter.rbUI, "PROC_IMP_IMAGES"));
                        }
                        if (i >= 90 && i < 100) {
                            DBImportWorker.this.prog.setText(GDMsgFormatter.getString(GDMsgFormatter.rbUI, "PROC_UPD_STASH"));
                        }
                        if (i >= 100) {
                            DBImportWorker.this.prog.setText(GDMsgFormatter.getString(GDMsgFormatter.rbUI, "PROG_LOAD_STASH"));
                        }
                    }
                }
            });
            this.prog.setVisible(true);
        }

        public Void doInBackground() {
            try {
                GDMsgLogger.clear();
                GDStashFrame.dbConfig.gddbInit = false;
                this.setProgress(0);
                this.completed = false;
                boolean processVanilla = true;
                final String mod = (String) GDConfigPane.this.cbMod.getSelectedItem();
                if (mod != null && !mod.isEmpty()) {
                    processVanilla = !GDConfigPane.this.cbModStandalone.isSelected();
                }
                String s = null;
                String order = null;
                boolean success = true;
                (GDStashFrame.arcList = GDConfigPane.this.getImportTextARCList()).decompress();
                if (GDMsgLogger.severeErrorsInLog()) {
                    success = false;
                }
                if (success) {
                    order = GDStashFrame.arcList.getTag(ARCDecompress.FileModule.GD, "tags_items.txt", "tagItemNameOrder", false);
                    if (order == null) {
                        final Object[] args = {"tagItemNameOrder", "tags_items.txt"};
                        final String msg = GDMsgFormatter.format(GDMsgFormatter.rbMsg, "ERR_TAG_NOT_FOUND", args);
                        GDMsgLogger.addError(msg);
                        success = false;
                    }
                }
                if (success) {
                    GDDBData.clearBuffers();
                    success = GDDBData.createDataTables();
                }
                if (success) {
                    DBEngineTagText.collectTags(GDStashFrame.arcList);
                    success = (success && DBConfig.setItemNameOrder("1.0.8", "1.8.0", order));
                    if (success) {
                        success = DBEngineTagText.storeTags();
                    }
                }
                if (success && mod != null && !mod.isEmpty()) {
                    final String db = GDConfigPane.this.getModDatabase();
                    if (db != null) {
                        this.setProgress(10);
                        (GDStashFrame.arz = new ARZDecompress(db)).decompress();
                        if (GDMsgLogger.severeErrorsInLog()) {
                            success = false;
                        }
                        if (success) {
                            success = GDStashFrame.arz.insertData(false);
                        }
                    }
                }
                if (GDStashFrame.arz != null) {
                    GDStashFrame.arz.clear();
                }
                if (success && processVanilla && GDStashFrame.expansionFangsOfAsterkarn) {
                    this.setProgress(20);
                    s = GDConfigPane.this.strGD + GDConstants.FILE_SEPARATOR + "gdx3" + GDConstants.FILE_SEPARATOR + "database" + GDConstants.FILE_SEPARATOR + "GDX3.arz";
                    (GDStashFrame.arz = new ARZDecompress(s)).decompress();
                    if (GDMsgLogger.severeErrorsInLog()) {
                        success = false;
                    }
                    this.setProgress(25);
                    if (success) {
                        success = GDStashFrame.arz.insertData(true);
                    }
                }
                if (GDStashFrame.arz != null) {
                    GDStashFrame.arz.clear();
                }
                if (success && processVanilla && GDStashFrame.expansionForgottenGods) {
                    this.setProgress(30);
                    s = GDConfigPane.this.strGD + GDConstants.FILE_SEPARATOR + "gdx2" + GDConstants.FILE_SEPARATOR + "database" + GDConstants.FILE_SEPARATOR + "GDX2.arz";
                    (GDStashFrame.arz = new ARZDecompress(s)).decompress();
                    if (GDMsgLogger.severeErrorsInLog()) {
                        success = false;
                    }
                    this.setProgress(35);
                    if (success) {
                        success = GDStashFrame.arz.insertData(true);
                    }
                }
                if (GDStashFrame.arz != null) {
                    GDStashFrame.arz.clear();
                }
                if (success && processVanilla && GDStashFrame.expansionAshesOfMalmouth) {
                    this.setProgress(40);
                    s = GDConfigPane.this.strGD + GDConstants.FILE_SEPARATOR + "gdx1" + GDConstants.FILE_SEPARATOR + "database" + GDConstants.FILE_SEPARATOR + "GDX1.arz";
                    (GDStashFrame.arz = new ARZDecompress(s)).decompress();
                    if (GDMsgLogger.severeErrorsInLog()) {
                        success = false;
                    }
                    this.setProgress(50);
                    if (success) {
                        success = GDStashFrame.arz.insertData(true);
                    }
                }
                if (GDStashFrame.arz != null) {
                    GDStashFrame.arz.clear();
                }
                if (success && processVanilla) {
                    this.setProgress(60);
                    s = GDConfigPane.this.strGD + GDConstants.FILE_SEPARATOR + "database" + GDConstants.FILE_SEPARATOR + "database.arz";
                    (GDStashFrame.arz = new ARZDecompress(s)).decompress();
                    if (GDMsgLogger.severeErrorsInLog()) {
                        success = false;
                    }
                    this.setProgress(70);
                    if (success) {
                        success = GDStashFrame.arz.insertData(true);
                    }
                }
                if (GDStashFrame.arz != null) {
                    GDStashFrame.arz.clear();
                }
                if (success) {
                    this.setProgress(80);
                    (GDStashFrame.arcList = GDConfigPane.this.getImportImageARCList()).updateImageData();
                    GDDBData.updateDB();
                }
                if (success && GDMsgLogger.severeErrorsInLog()) {
                    success = false;
                }
                if (success) {
                    this.setProgress(90);
                    success = GDDBData.updateStash();
                    if (GDMsgLogger.severeErrorsInLog()) {
                        success = false;
                    }
                }
                if (success) {
                    success = (success && DBConfig.setVersions("1.0.8", "1.8.0"));
                    this.setProgress(100);
                }
                success = (success && DBConfig.setGDDBInit("1.0.8", "1.8.0", success));
                if (success) {
                    final String msg2 = GDMsgFormatter.getString(GDMsgFormatter.rbUI, "SUCC_DB_IMPORT");
                    GDMsgLogger.addSuccess(msg2);
                    GDStashFrame.dbConfig.gddbInit = success;
                    GDConfigPane.this.initData();
                }
                if (success) {
                    GDStashInfoList.findStashes(GDConfigPane.this.frame, null, null);
                    if (GDConfigPane.this.frame.pnlTransfer != null) {
                        GDConfigPane.this.frame.pnlTransfer.setStash(GDStashInfoList.defaultStash);
                    }
                    if (GDConfigPane.this.frame.pnlCraft != null) {
                        GDConfigPane.this.frame.pnlCraft.setStash(GDStashInfoList.defaultStash);
                    }
                    GDCharInfoList.findChars(GDConfigPane.this.frame, null);
                    if (GDConfigPane.this.frame.pnlCharInventory != null) {
                        GDConfigPane.this.frame.pnlCharInventory.initCharSelection();
                    }
                    if (GDConfigPane.this.frame.pnlCharEdit != null) {
                        GDConfigPane.this.frame.pnlCharEdit.initCharSelection();
                    }
                    GDConfigPane.this.frame.refresh();
                    this.completed = true;
                }
            } catch (Throwable ex) {
                GDMsgLogger.addError(ex);
                this.completed = false;
            }
            return null;
        }

        public void done() {
            this.prog.setVisible(false);
            this.prog.dispose();
            if (!this.completed && !GDMsgLogger.severeErrorsInLog()) {
                GDMsgLogger.addError(GDMsgFormatter.getString(GDMsgFormatter.rbUI, "ERR_DB_IMPORT"));
            }
            GDStashFrame.arcList = null;
            if (GDStashFrame.arz != null) {
                GDStashFrame.arz.clear();
                GDStashFrame.arz = null;
            }
            GDConfigPane.this.setCursor(Cursor.getDefaultCursor());
            GDMsgLogger.showSevereLog(GDConfigPane.this, GDMsgFormatter.getString(GDMsgFormatter.rbUI, "SUCC_DB_IMPORT"), GDLog.MessageType.Success, GDMsgFormatter.getString(GDMsgFormatter.rbUI, "ERR_DB_IMPORT"), true, false);
        }
    }

    private class ARZExportWorker extends SwingWorker<Void, Void> {
        private GDProgressDialog prog;
        private boolean completed;

        public ARZExportWorker() {
            GDConfigPane.this.setCursor(Cursor.getPredefinedCursor(3));
            this.prog = new GDProgressDialog(GDConfigPane.this.frame, GDMsgFormatter.getString(GDMsgFormatter.rbUI, "PROG_EXP_ARCS"));
            this.completed = false;
            this.addPropertyChangeListener(new PropertyChangeListener() {
                @Override
                public void propertyChange(final PropertyChangeEvent e) {
                    if (e.getPropertyName().equals("progress")) {
                        final int i = (int) e.getNewValue();
                        if (i < 30) {
                            ARZExportWorker.this.prog.setText(GDMsgFormatter.getString(GDMsgFormatter.rbUI, "PROG_EXP_ARCS"));
                        }
                        if (i >= 30 && i < 70) {
                            ARZExportWorker.this.prog.setText(GDMsgFormatter.getString(GDMsgFormatter.rbUI, "PROG_DEC_DB_ARZ"));
                        }
                        if (i >= 70) {
                            ARZExportWorker.this.prog.setText(GDMsgFormatter.getString(GDMsgFormatter.rbUI, "PROC_EXP_DB_ARZ"));
                        }
                    }
                }
            });
            this.prog.setVisible(true);
        }

        public Void doInBackground() {
            GDMsgLogger.clear();
            this.setProgress(0);
            this.completed = false;
            boolean success = true;
            String db = GDConfigPane.this.getModDatabase();
            final boolean isMod = db != null;
            if (!isMod) {
                db = GDConfigPane.this.strGD + GDConstants.FILE_SEPARATOR + "database" + GDConstants.FILE_SEPARATOR + "database.arz";
            }
            (GDStashFrame.arcList = GDConfigPane.this.getExportARCList()).writeFiles(GDConfigPane.this.strExport, !isMod);
            this.setProgress(30);
            (GDStashFrame.arz = new ARZDecompress(db)).decompress();
            GDStashFrame.arz.extractRecords(GDConfigPane.this.strExport);
            this.setProgress(90);
            if (GDMsgLogger.errorsInLog()) {
                success = false;
            }
            if (success) {
                this.completed = true;
            }
            return null;
        }

        public void done() {
            this.prog.setVisible(false);
            this.prog.dispose();
            if (!this.completed && !GDMsgLogger.errorsInLog()) {
                GDMsgLogger.addError(GDMsgFormatter.getString(GDMsgFormatter.rbUI, "ERR_DB_EXPORT"));
            }
            GDStashFrame.arcList = null;
            if (GDStashFrame.arz != null) {
                GDStashFrame.arz.clear();
                GDStashFrame.arz = null;
            }
            GDConfigPane.this.setCursor(Cursor.getDefaultCursor());
            GDMsgLogger.showLog(GDConfigPane.this, GDMsgFormatter.getString(GDMsgFormatter.rbUI, "SUCC_DB_EXPORT"), GDLog.MessageType.Success, GDMsgFormatter.getString(GDMsgFormatter.rbUI, "ERR_DB_EXPORT"), true, false);
        }
    }

    private class TextureConvertWorker extends SwingWorker<Void, Void> {
        private GDProgressDialog prog;
        private boolean completed;

        public TextureConvertWorker() {
            GDConfigPane.this.setCursor(Cursor.getPredefinedCursor(3));
            this.prog = new GDProgressDialog(GDConfigPane.this.frame, GDMsgFormatter.getString(GDMsgFormatter.rbUI, "PROG_CONVERT_TEX"));
            this.completed = false;
            this.prog.setVisible(true);
        }

        public Void doInBackground() {
            GDMsgLogger.clear();
            this.completed = false;
            boolean success = true;
            ARZDecompress.convertTextures(GDConfigPane.this.strExport);
            if (GDMsgLogger.errorsInLog()) {
                success = false;
            }
            if (success) {
                this.completed = true;
            }
            return null;
        }

        public void done() {
            this.prog.setVisible(false);
            this.prog.dispose();
            if (!this.completed && !GDMsgLogger.errorsInLog()) {
                GDMsgLogger.addError(GDMsgFormatter.getString(GDMsgFormatter.rbUI, "ERR_TEX_CONVERT"));
            }
            GDConfigPane.this.setCursor(Cursor.getDefaultCursor());
            GDMsgLogger.showLog(GDConfigPane.this, GDMsgFormatter.getString(GDMsgFormatter.rbUI, "SUCC_TEX_CONVERT"), GDLog.MessageType.Success, GDMsgFormatter.getString(GDMsgFormatter.rbUI, "ERR_TEX_CONVERT"), true, false);
        }
    }

    private class GDDirListener implements ActionListener {
        @Override
        public void actionPerformed(final ActionEvent e) {
            final JFileChooser chooser = new JFileChooser(GDConfigPane.this.dirGD);
            chooser.setFileSelectionMode(1);
            chooser.setAcceptAllFileFilterUsed(false);
            if (chooser.showOpenDialog(GDConfigPane.this) == 0) {
                GDConfigPane.this.dirGD = chooser.getSelectedFile();
                try {
                    String s = GDConfigPane.this.dirGD.getCanonicalPath();
                    if (GDConfigPane.this.isCorrectInstallDir(s)) {
                        GDConfigPane.this.strGD = s;
                        GDConfigPane.this.lblGD.setText(GDConfigPane.this.strGD);
                        GDConfigPane.this.cbMod.setModel(GDConfigPane.this.buildModModel());
                        GDConfigPane.this.cbGDLocal.setModel(GDConfigPane.this.buildGDLanguageModel());
                        s = GDConfigPane.this.strGD + GDConstants.FILE_SEPARATOR + "gdx1" + GDConstants.FILE_SEPARATOR + "database" + GDConstants.FILE_SEPARATOR + "GDX1.arz";
                        final File fGDX1 = new File(s);
                        GDStashFrame.expansionAshesOfMalmouth = fGDX1.exists();
                        s = GDConfigPane.this.strGD + GDConstants.FILE_SEPARATOR + "gdx2" + GDConstants.FILE_SEPARATOR + "database" + GDConstants.FILE_SEPARATOR + "GDX2.arz";
                        final File fGDX2 = new File(s);
                        GDStashFrame.expansionForgottenGods = fGDX2.exists();
                        s = GDConfigPane.this.strGD + GDConstants.FILE_SEPARATOR + "gdx3" + GDConstants.FILE_SEPARATOR + "database" + GDConstants.FILE_SEPARATOR + "GDX3.arz";
                        final File fGDX3 = new File(s);
                        GDStashFrame.expansionFangsOfAsterkarn = fGDX3.exists();
                    } else {
                        final GDDialog dialog = new GDDialog(GDMsgFormatter.getString(GDMsgFormatter.rbUI, "ERR_WRONG_DIR"), 4, GDConfigPane.this.frame, GDMsgFormatter.getString(GDMsgFormatter.rbUI, "ERROR"), true);
                        dialog.setVisible(true);
                    }
                } catch (IOException ex) {
                }
            }
            GDMsgLogger.showLog(GDConfigPane.this, GDMsgFormatter.getString(GDMsgFormatter.rbUI, "ERRORS"));
        }
    }

    private class SaveDirListener implements ActionListener {
        @Override
        public void actionPerformed(final ActionEvent e) {
            final JFileChooser chooser = new JFileChooser(GDConfigPane.this.dirSave);
            chooser.setFileSelectionMode(1);
            chooser.setAcceptAllFileFilterUsed(false);
            if (chooser.showOpenDialog(GDConfigPane.this) == 0) {
                GDConfigPane.this.dirSave = chooser.getSelectedFile();
                try {
                    final String s = GDConfigPane.this.dirSave.getCanonicalPath();
                    if (GDConfigPane.this.isCorrectSaveDir(s)) {
                        GDConfigPane.this.strSave = s;
                        GDConfigPane.this.lblSave.setText(GDConfigPane.this.strSave);
                        if (GDStashFrame.dbConfig.gddbInit) {
                            GDStashFrame.iniConfig.sectDir.savePath = GDConfigPane.this.strSave;
                            GDStashInfoList.findStashes(GDConfigPane.this.frame, null, null);
                            GDCharInfoList.findChars(GDConfigPane.this.frame, null);
                            GDConfigPane.this.frame.pnlTransfer.setStashInfo(GDStashInfoList.defaultStash);
                            GDConfigPane.this.frame.pnlCraft.setStashInfo(GDStashInfoList.defaultStash);
                        }
                    } else {
                        final GDDialog dialog = new GDDialog(GDMsgFormatter.getString(GDMsgFormatter.rbUI, "ERR_WRONG_DIR"), 4, GDConfigPane.this.frame, GDMsgFormatter.getString(GDMsgFormatter.rbUI, "ERROR"), true);
                        dialog.setVisible(true);
                    }
                } catch (IOException ex) {
                }
            }
            GDMsgLogger.showLog(GDConfigPane.this, GDMsgFormatter.getString(GDMsgFormatter.rbUI, "ERRORS"));
        }
    }

    private class ExportDirListener implements ActionListener {
        @Override
        public void actionPerformed(final ActionEvent e) {
            final JFileChooser chooser = new JFileChooser(GDConfigPane.this.dirExport);
            chooser.setFileSelectionMode(1);
            chooser.setAcceptAllFileFilterUsed(false);
            if (chooser.showOpenDialog(GDConfigPane.this) == 0) {
                GDConfigPane.this.dirExport = chooser.getSelectedFile();
                try {
                    final String s = GDConfigPane.this.dirExport.getCanonicalPath();
                    GDConfigPane.this.strExport = s;
                    GDConfigPane.this.lblExport.setText(GDConfigPane.this.strExport);
                } catch (IOException ex) {
                }
            }
            GDMsgLogger.showLog(GDConfigPane.this, GDMsgFormatter.getString(GDMsgFormatter.rbUI, "ERRORS"));
        }
    }

    private class ModListener implements ActionListener {
        @Override
        public void actionPerformed(final ActionEvent e) {
            GDStashFrame.iniConfig.sectHistory.lastMod = (String) GDConfigPane.this.cbMod.getSelectedItem();
            GDConfigPane.this.initData();
            GDMsgLogger.showLog(GDConfigPane.this, GDMsgFormatter.getString(GDMsgFormatter.rbUI, "MESSAGES"), GDLog.MessageType.Info, GDMsgFormatter.getString(GDMsgFormatter.rbUI, "ERRORS"), false, false);
        }
    }

    private class LocalizationListener implements ActionListener {
        @Override
        public void actionPerformed(final ActionEvent e) {
            GDStashFrame.dbConfig.gdLocal = (String) GDConfigPane.this.cbGDLocal.getSelectedItem();
        }
    }

    private class LanguageListener implements ActionListener {
        @Override
        public void actionPerformed(final ActionEvent e) {
            GDStashFrame.iniConfig.sectUI.language = (String) GDConfigPane.this.cbLanguage.getSelectedItem();
            try {
                GDStashFrame.setGDLocale(GDStashFrame.iniConfig.sectUI.language, GDConfigPane.this.frame);
            } catch (IOException ex) {
                GDMsgLogger.addError(ex);
            }
            GDMsgLogger.showLog(GDConfigPane.this, GDMsgFormatter.getString(GDMsgFormatter.rbUI, "ERRORS"));
        }
    }

    private class LookNFeelListener implements ActionListener {
        @Override
        public void actionPerformed(final ActionEvent e) {
            final String sLnF = (String) GDConfigPane.this.cbLookNFeel.getSelectedItem();
            try {
                final UIManager.LookAndFeelInfo[] info = UIManager.getInstalledLookAndFeels();
                for (int i = 0; i < info.length; ++i) {
                    if (info[i].getName().equals(sLnF)) {
                        GDColor.setLookAndFeelUI(info[i].getClassName());
                        UIManager.setLookAndFeel(info[i].getClassName());
                        if (info[i].getClassName().equals("com.seaglasslookandfeel.SeaGlassLookAndFeel")) {
                            final Font fntLabel = UIManager.getDefaults().getFont("Label.font");
                            if (fntLabel == null) {
                                UIManager.put("Label.font", new Font("Consolas", 0, 12));
                            }
                        }
                        SwingUtilities.updateComponentTreeUI(GDConfigPane.this.frame);
                        GDStashFrame.iniConfig.sectUI.lookNFeel = info[i].getName();
                        GDStashFrame.adjustUI(GDConfigPane.this.frame);
                        break;
                    }
                }
            } catch (Exception ex) {
                cbLookNFeel.setSelectedItem(GDStashFrame.iniConfig.sectUI.lookNFeel);
            }
            GDMsgLogger.showLog(GDConfigPane.this, GDMsgFormatter.getString(GDMsgFormatter.rbUI, "ERRORS"));
        }
    }

    private class FontSizeListener implements ActionListener {
        @Override
        public void actionPerformed(final ActionEvent e) {
            GDStashFrame.iniConfig.sectUI.fontSize = Integer.parseInt((String) GDConfigPane.this.cbFontSize.getSelectedItem());
            GDImagePool.loadImages();
            GDStashFrame.adjustUI(GDConfigPane.this.frame);
            GDMsgLogger.showLog(GDConfigPane.this, GDMsgFormatter.getString(GDMsgFormatter.rbUI, "ERRORS"));
        }
    }

    private class GraphicScaleListener implements ActionListener {
        @Override
        public void actionPerformed(final ActionEvent e) {
            String s = (String) GDConfigPane.this.cbGraphicScale.getSelectedItem();
            final int pos = s.indexOf("%");
            if (pos != -1) {
                s = s.substring(0, pos);
            }
            GDStashFrame.iniConfig.sectUI.graphicScale = Integer.parseInt(s);
            GDStashFrame.adjustUI(GDConfigPane.this.frame);
            GDMsgLogger.showLog(GDConfigPane.this, GDMsgFormatter.getString(GDMsgFormatter.rbUI, "ERRORS"));
        }
    }

    private class MinimizeTrayListener implements ActionListener {
        @Override
        public void actionPerformed(final ActionEvent e) {
            GDStashFrame.iniConfig.sectUI.minimizeToTray = GDConfigPane.this.cbMinimizeTray.isSelected();
            if (GDConfigPane.this.frame.trayIcon != null && SystemTray.isSupported()) {
                GDConfigPane.this.frame.tray = SystemTray.getSystemTray();
                if (GDStashFrame.iniConfig.sectUI.minimizeToTray) {
                    try {
                        GDConfigPane.this.frame.tray.add(GDConfigPane.this.frame.trayIcon);
                    } catch (Exception ex) {
                        GDConfigPane.this.frame.tray = null;
                    }
                } else {
                    GDConfigPane.this.frame.tray.remove(GDConfigPane.this.frame.trayIcon);
                }
            }
        }
    }

    private class EditListener implements ActionListener {
        @Override
        public void actionPerformed(final ActionEvent e) {
            GDStashFrame.iniConfig.sectRestrict.allowEdit = GDConfigPane.this.cbAllowEdit.isSelected();
            GDConfigPane.this.frame.pnlTabbed.setEdit(GDStashFrame.iniConfig.sectRestrict.allowEdit);
            GDMsgLogger.showLog(GDConfigPane.this, GDMsgFormatter.getString(GDMsgFormatter.rbUI, "ERRORS"));
        }
    }

    private class HCSCListener implements ActionListener {
        @Override
        public void actionPerformed(final ActionEvent e) {
            if (!(GDStashFrame.iniConfig.sectRestrict.transferSCHC = GDConfigPane.this.cbTransSCHC.isSelected())) {
                GDConfigPane.this.frame.pnlTransfer.clearSelItems();
            }
            GDMsgLogger.showLog(GDConfigPane.this, GDMsgFormatter.getString(GDMsgFormatter.rbUI, "ERRORS"));
        }
    }

    private class SoulboundListener implements ActionListener {
        @Override
        public void actionPerformed(final ActionEvent e) {
            if (!(GDStashFrame.iniConfig.sectRestrict.transferSoulbound = GDConfigPane.this.cbTransSoul.isSelected())) {
                GDConfigPane.this.frame.pnlTransfer.clearSelItems();
            }
            GDMsgLogger.showLog(GDConfigPane.this, GDMsgFormatter.getString(GDMsgFormatter.rbUI, "ERRORS"));
        }
    }

    private class CompletionListener implements ActionListener {
        @Override
        public void actionPerformed(final ActionEvent e) {
            GDStashFrame.iniConfig.sectRestrict.completionAll = GDConfigPane.this.cbCompletionAll.isSelected();
        }
    }

    private class BlacksmithListener implements ActionListener {
        @Override
        public void actionPerformed(final ActionEvent e) {
            GDStashFrame.iniConfig.sectRestrict.blacksmithAll = GDConfigPane.this.cbBlacksmithAll.isSelected();
        }
    }

    private class AffixComboListener implements ActionListener {
        @Override
        public void actionPerformed(final ActionEvent e) {
            if (GDConfigPane.this.rbCombiValid.isSelected()) {
                GDStashFrame.iniConfig.sectRestrict.affixCombi = 1;
            }
            if (GDConfigPane.this.rbCombiAllCombos.isSelected()) {
                GDStashFrame.iniConfig.sectRestrict.affixCombi = 2;
            }
            if (GDConfigPane.this.rbCombiAllAffixes.isSelected()) {
                GDStashFrame.iniConfig.sectRestrict.affixCombi = 3;
            }
        }
    }

    private class DBStashMoveListener implements ActionListener {
        @Override
        public void actionPerformed(final ActionEvent e) {
            final int i = GDConfigPane.this.cbDBStashMove.getSelectedIndex();
            GDStashFrame.iniConfig.sectRestrict.dbStashMove = (i == 1);
        }
    }

    private class ConfigListener implements ActionListener {
        @Override
        public void actionPerformed(final ActionEvent e) {
            if (GDConfigPane.this.isCorrectDirs()) {
                boolean success = true;
                final DBConfig dbConfig = (DBConfig) GDStashFrame.dbConfig.clone();
                dbConfig.gdLocal = (String) GDConfigPane.this.cbGDLocal.getSelectedItem();
                dbConfig.modStandalone = GDConfigPane.this.cbModStandalone.isSelected();
                success = DBConfig.setConfigData("1.0.8", "1.8.0", dbConfig);
                if (success) {
                    GDStashFrame.dbConfig = dbConfig;
                    success = (success && DBConfig.setConfigInit("1.0.8", "1.8.0", success));
                    success = (success && DBConfig.setVersions("1.0.8", "1.8.0"));
                }
                GDStashFrame.iniConfig.sectDir.gdPath = GDConfigPane.this.strGD;
                GDStashFrame.iniConfig.sectDir.savePath = GDConfigPane.this.strSave;
                GDStashFrame.iniConfig.sectDir.exportPath = GDConfigPane.this.strExport;
                GDStashFrame.iniConfig.sectUI.language = (String) GDConfigPane.this.cbLanguage.getSelectedItem();
                GDStashFrame.iniConfig.sectRestrict.transferSCHC = GDConfigPane.this.cbTransSCHC.isSelected();
                GDStashFrame.iniConfig.sectRestrict.transferSoulbound = GDConfigPane.this.cbTransSoul.isSelected();
                GDStashFrame.iniConfig.sectRestrict.completionAll = GDConfigPane.this.cbCompletionAll.isSelected();
                GDStashFrame.iniConfig.sectRestrict.blacksmithAll = GDConfigPane.this.cbBlacksmithAll.isSelected();
                GDStashFrame.iniConfig.sectRestrict.affixCombi = 1;
                if (GDConfigPane.this.rbCombiAllCombos.isSelected()) {
                    GDStashFrame.iniConfig.sectRestrict.affixCombi = 2;
                }
                if (GDConfigPane.this.rbCombiAllAffixes.isSelected()) {
                    GDStashFrame.iniConfig.sectRestrict.affixCombi = 3;
                }
                GDStashFrame.iniConfig.sectRestrict.dbStashMove = (GDConfigPane.this.cbDBStashMove.getSelectedIndex() == 1);
                GDStashFrame.dbConfig.configInit = GDStashFrame.iniConfig.write();
                GDConfigPane.this.frame.checkTabs();
                GDMsgLogger.showLog(GDConfigPane.this, GDMsgFormatter.getString(GDMsgFormatter.rbUI, "SUCC_SETTINGS_SAVE"), GDLog.MessageType.Success, GDMsgFormatter.getString(GDMsgFormatter.rbUI, "ERR_SETTINGS_SAVE"), true, false);
            } else {
                final GDDialog dialog = new GDDialog(GDMsgFormatter.getString(GDMsgFormatter.rbUI, "ERR_SPEC_DIRS"), 4, GDConfigPane.this.frame, GDMsgFormatter.getString(GDMsgFormatter.rbUI, "ERROR"), true);
                dialog.setVisible(true);
            }
        }
    }

    private class DBImportListener implements ActionListener {
        @Override
        public void actionPerformed(final ActionEvent e) {
            if (GDConfigPane.this.isCorrectDirs()) {
                final DBImportWorker worker = new DBImportWorker();
                worker.execute();
                GDMsgLogger.showLog(GDConfigPane.this, GDMsgFormatter.getString(GDMsgFormatter.rbUI, "MESSAGES"), GDLog.MessageType.Info, GDMsgFormatter.getString(GDMsgFormatter.rbUI, "ERRORS"), false, false);
            } else {
                final GDDialog dialog = new GDDialog(GDMsgFormatter.getString(GDMsgFormatter.rbUI, "ERR_WRONG_DIR"), 4, GDConfigPane.this.frame, GDMsgFormatter.getString(GDMsgFormatter.rbUI, "ERROR"), true);
                dialog.setVisible(true);
            }
        }
    }

    private class ARZExportListener implements ActionListener {
        @Override
        public void actionPerformed(final ActionEvent e) {
            if (GDConfigPane.this.isCorrectDirs()) {
                final ARZExportWorker worker = new ARZExportWorker();
                worker.execute();
            } else {
                final GDDialog dialog = new GDDialog(GDMsgFormatter.getString(GDMsgFormatter.rbUI, "ERR_WRONG_DIR"), 4, GDConfigPane.this.frame, GDMsgFormatter.getString(GDMsgFormatter.rbUI, "ERROR"), true);
                dialog.setVisible(true);
            }
        }
    }

    private class DevotionListener implements ActionListener {
        @Override
        public void actionPerformed(final ActionEvent e) {
            final String fn = GDConfigPane.this.strExport + GDConstants.FILE_SEPARATOR + "devotions.txt";
            DBConstellation.createFile(fn);
        }
    }

    private class TextureConversionListener implements ActionListener {
        @Override
        public void actionPerformed(final ActionEvent e) {
            if (GDConfigPane.this.isCorrectDirs()) {
                final TextureConvertWorker worker = new TextureConvertWorker();
                worker.execute();
            } else {
                final GDDialog dialog = new GDDialog(GDMsgFormatter.getString(GDMsgFormatter.rbUI, "ERR_WRONG_DIR"), 4, GDConfigPane.this.frame, GDMsgFormatter.getString(GDMsgFormatter.rbUI, "ERROR"), true);
                dialog.setVisible(true);
            }
        }
    }
}
